From cbed1912633def1b6c1ac1369b28a99825b81d0a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 9 Mar 2015 11:38:46 -0700 Subject: [PATCH] Reduce usage of unstable features --- src/bin/bench.rs | 6 +++--- src/bin/build.rs | 4 ++-- src/bin/cargo.rs | 9 ++++----- src/bin/clean.rs | 4 ++-- src/bin/doc.rs | 2 +- src/bin/login.rs | 7 +++++-- src/bin/pkgid.rs | 2 +- src/bin/run.rs | 2 +- src/bin/test.rs | 6 +++--- src/bin/update.rs | 4 ++-- src/bin/verify_project.rs | 5 ++--- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 00edc0051..d910784e6 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -51,17 +51,17 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { config.shell().set_verbose(options.flag_verbose); let ops = ops::TestOptions { - name: options.flag_bench.as_ref().map(|s| s.as_slice()), + name: options.flag_bench.as_ref().map(|s| &s[..]), no_run: options.flag_no_run, compile_opts: ops::CompileOptions { env: "bench", config: config, jobs: options.flag_jobs, - target: options.flag_target.as_ref().map(|s| s.as_slice()), + target: options.flag_target.as_ref().map(|s| &s[..]), dev_deps: true, features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| s.as_slice()), + spec: options.flag_package.as_ref().map(|s| &s[..]), lib_only: false, exec_engine: None, }, diff --git a/src/bin/build.rs b/src/bin/build.rs index 0784c047a..3408f4077 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -62,11 +62,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { env: env, config: config, jobs: options.flag_jobs, - target: options.flag_target.as_ref().map(|t| t.as_slice()), + target: options.flag_target.as_ref().map(|t| &t[..]), dev_deps: false, features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| s.as_slice()), + spec: options.flag_package.as_ref().map(|s| &s[..]), lib_only: options.flag_lib, exec_engine: None, }; diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index c381d728a..7707762cd 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -1,4 +1,4 @@ -#![feature(collections, core, io, path, fs, std_misc, os, old_io, exit_status)] +#![feature(core, io, path, std_misc, exit_status)] extern crate "git2-curl" as git2_curl; extern crate "rustc-serialize" as rustc_serialize; @@ -10,7 +10,6 @@ extern crate toml; use std::collections::BTreeSet; use std::env; use std::fs; -use std::io::prelude::*; use std::io; use std::path::{PathBuf, Path}; use std::process::Command; @@ -210,7 +209,7 @@ fn list_commands() -> BTreeSet { let command = &filename[ command_prefix.len().. filename.len() - env::consts::EXE_SUFFIX.len()]; - commands.insert(String::from_str(command)); + commands.insert(command.to_string()); } } } @@ -225,7 +224,7 @@ fn list_commands() -> BTreeSet { #[cfg(unix)] fn is_executable(path: &Path) -> bool { use std::os::unix::prelude::*; - path.metadata().map(|m| { + fs::metadata(path).map(|m| { m.permissions().mode() & 0o001 == 0o001 }).unwrap_or(false) } @@ -239,7 +238,7 @@ fn find_command(cmd: &str) -> Option { let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX); let dirs = list_command_directory(); let mut command_paths = dirs.iter().map(|dir| dir.join(&command_exe)); - command_paths.find(|path| path.exists()) + command_paths.find(|path| fs::metadata(&path).is_ok()) } /// List candidate locations where subcommands might be installed. diff --git a/src/bin/clean.rs b/src/bin/clean.rs index a530b9b24..cc66f29fd 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -38,8 +38,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); let opts = ops::CleanOptions { config: config, - spec: options.flag_package.as_ref().map(|s| s.as_slice()), - target: options.flag_target.as_ref().map(|s| s.as_slice()), + spec: options.flag_package.as_ref().map(|s| &s[..]), + target: options.flag_target.as_ref().map(|s| &s[..]), }; ops::clean(&root, &opts).map(|_| None).map_err(|err| { CliError::from_boxed(err, 101) diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 0aba6b5bb..dbb1b5ab4 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -56,7 +56,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { dev_deps: false, features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| s.as_slice()), + spec: options.flag_package.as_ref().map(|s| &s[..]), lib_only: false, exec_engine: None, }, diff --git a/src/bin/login.rs b/src/bin/login.rs index 2726c937c..16c8f7c85 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -1,4 +1,5 @@ -use std::old_io; +use std::io::prelude::*; +use std::io; use cargo::ops; use cargo::core::{SourceId, Source}; @@ -38,7 +39,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let host = options.flag_host.clone().unwrap_or(config.api); println!("please visit {}me and paste the API Token below", host); - let line = try!(old_io::stdin().read_line()); + let mut line = String::new(); + let input = io::stdin(); + try!(input.lock().read_line(&mut line)); Ok(line) })(); diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index f0409b11f..c5fe8de37 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -46,7 +46,7 @@ pub fn execute(options: Options, config.shell().set_verbose(options.flag_verbose); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path.clone())); - let spec = options.arg_spec.as_ref().map(|s| s.as_slice()); + let spec = options.arg_spec.as_ref().map(|s| &s[..]); let spec = try!(ops::pkgid(&root, spec, config).map_err(|err| { CliError::from_boxed(err, 101) })); diff --git a/src/bin/run.rs b/src/bin/run.rs index 2b8c7b973..f786832a2 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -57,7 +57,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { env: env, config: config, jobs: options.flag_jobs, - target: options.flag_target.as_ref().map(|t| t.as_slice()), + target: options.flag_target.as_ref().map(|t| &t[..]), dev_deps: true, features: &options.flag_features, no_default_features: options.flag_no_default_features, diff --git a/src/bin/test.rs b/src/bin/test.rs index 7eedac427..6c7e18e63 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -53,17 +53,17 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { config.shell().set_verbose(options.flag_verbose); let ops = ops::TestOptions { - name: options.flag_test.as_ref().map(|s| s.as_slice()), + name: options.flag_test.as_ref().map(|s| &s[..]), no_run: options.flag_no_run, compile_opts: ops::CompileOptions { env: "test", config: config, jobs: options.flag_jobs, - target: options.flag_target.as_ref().map(|s| s.as_slice()), + target: options.flag_target.as_ref().map(|s| &s[..]), dev_deps: true, features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| s.as_slice()), + spec: options.flag_package.as_ref().map(|s| &s[..]), lib_only: false, exec_engine: None, }, diff --git a/src/bin/update.rs b/src/bin/update.rs index 4fdeebfb6..61df563d3 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -57,8 +57,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let update_opts = ops::UpdateOptions { aggressive: options.flag_aggressive, - precise: options.flag_precise.as_ref().map(|s| s.as_slice()), - to_update: spec.map(|s| s.as_slice()), + precise: options.flag_precise.as_ref().map(|s| &s[..]), + to_update: spec.map(|s| &s[..]), config: config, }; diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 33c271a9e..43056c13d 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -32,10 +32,9 @@ pub fn execute(args: Flags, config: &Config) -> CliResult> { let file = File::open(&args.flag_manifest_path); match file.and_then(|mut f| f.read_to_string(&mut contents)) { Ok(()) => {}, - Err(e) => return fail("invalid", format!("error reading file: {}", - e).as_slice()) + Err(e) => return fail("invalid", &format!("error reading file: {}", e)) }; - match toml::Parser::new(contents.as_slice()).parse() { + match toml::Parser::new(&contents).parse() { None => return fail("invalid", "invalid-format"), Some(..) => {} }; -- 2.30.2